package com.library.service;

import com.library.bean.Lend;
import com.library.bean.LendExpand;
import com.library.dao.LendDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class LendService {
    @Autowired
    private LendDao lendDao;

    public boolean   lendBookApply( long book_id,  long reader_id){
        return lendDao.lendBookApply(book_id, reader_id) > 0;
    }

    public boolean returnBook(long bookId, long readerId){
        return lendDao.returnBookOne(bookId, readerId)>0 && lendDao.returnBookTwo(bookId)>0;
    }

    public boolean lendBook(long ser_num,long bookId){
        return lendDao.lendBookOne(ser_num)>0 && lendDao.lendBookTwo(bookId)>0;
    }

    public ArrayList<Lend> lendList(){
        return lendDao.lendList();
    }

    public ArrayList<LendExpand> LendExpandList(){
        return lendDao.LendExpandList();
    }
    public ArrayList<LendExpand> LendExpandListNoReturnByReaderId(long reader_id){
        return lendDao.LendExpandListNoReturnByReaderId(reader_id);
    }
    public ArrayList<LendExpand> LendExpandListApplyingByReaderId(long reader_id){
        return lendDao.LendExpandListApplyingByReaderId(reader_id);
    }

    public ArrayList<Lend> myLendList(long readerId){
        return lendDao.myLendList(readerId);
    }

    public ArrayList<LendExpand> myLendExpandList(long readerId){
        return lendDao.myLendExpandList(readerId);
    }

    public int deleteLend(long serNum) {
        return lendDao.deleteLend(serNum);
    }

}
